 <!-- Timeline CSS -->
    <link href="<?php echo $baseurl.'public';?>/dist/css/timeline.css" rel="stylesheet">
    
    <!-- Flot Charts JavaScript -->
    <script src="<?php echo $baseurl?>public/bower_components/flot/excanvas.min.js"></script>
    <script src="<?php echo $baseurl?>public/bower_components/flot/jquery.flot.js"></script>
    <script src="<?php echo $baseurl?>public/bower_components/flot/jquery.flot.pie.js"></script>
    <script src="<?php echo $baseurl?>public/bower_components/flot/jquery.flot.resize.js"></script>
    <script src="<?php echo $baseurl?>public/bower_components/flot/jquery.flot.time.js"></script>
    <script src="<?php echo $baseurl?>public/bower_components/flot.tooltip/js/jquery.flot.tooltip.min.js"></script>
    
    <!-- Morris Charts JavaScript -->
    <script src="<?php echo $baseurl?>public/bower_components/raphael/raphael.js"></script>
    <script src="<?php echo $baseurl?>public/bower_components/morrisjs/morris.min.js"></script>
     <!-- Metis Menu Plugin JavaScript -->
    <script src="<?php echo $baseurl.'public';?>/bower_components/metisMenu/dist/metisMenu.min.js"></script>

<div class="row">
        
	<div class="col-lg-12">
		<div class=""> 
			<h2><button type="button" class="btn btn-primary btn-circle btn-lg"><i class="fa fa-home"></i>
                            </button> <?php echo $data->project_name;?></h2>
			
			
			
			<p class="text-muted"><i class="fa fa-clock-o"></i> <?php echo ' Thời gian tạo : '.date('H:i d-m-Y',strtotime($data->created)).' bởi '.$data->fullname;?> </p>
			
			<p class="text-muted"><i class="fa fa-share-square"></i> <?php echo ' Thời gian hoạt động '.date('H:i d-m-Y',strtotime($data->time_start)).' - '.date('H:i d-m-Y',strtotime($data->time_end));?></p>
			<p>
			
			<p class="text-muted"><i class="fa fa-smile-o"></i> Trạng thái : <?php echo $fview->U_getStatusProject($data->status,$data->time_end);?></p>
			<p class="text-muted"><i class="fa fa-link"></i> Link google docs : <a target="_blank" href="<?php echo $data->linkdocs;?>">Xem chi tiết</a></p>
			<p>			
			 <i class="fa fa-info-circle"></i> Mô tả : <br>
			<?php echo $data->content;?>
			</p>
			<p class="text-muted"><i class="fa fa-user"></i> Những người tham gia dự án: <?php $i=1;$k=count($data->project_user); foreach ( $data->project_user AS $el1=>$le1 ){ ?>
                        <a href="<?php echo site_url('report-user')."?us=".$le1->id;?>"><?php echo $le1->fullname;?></a><?php if($i < $k) {?>  ,<?php }$i++;  ?> 
			<?php } ?> </p>
                        <p class="text-muted"><i class="fa fa-user"></i> <span>Người đang được thống kê:<a href="<?php echo site_url('report-user')."?us=".$data->user_report->id;?>" style="font-weight:bold;"> <?php echo $data->user_report->fullname;?></a> 
			</p>
			<?php if($this->session->userdata("level") == 1 && $data->user_report->id != $this->session->userdata("admin_id")){ ?>
                        <p>
                            <a  class = "btn btn-primary " href="send-mail?us=<?php echo $data->user_report->id; ?>">Gửi email đến <?php echo $data->user_report->fullname; ?> </a>
                        </p>
                        <?php } ?>
			
			<div>
				<p>
					<strong><i class="fa fa-rocket"></i> Tiến độ công việc</strong>
					<span class="pull-right text-muted text-warning">Hoàn thành <?php echo $data->avg_user;?>% </span>
				</p>
				<div class="progress progress-striped active">
					<div class="progress-bar <?php echo $fview->U_getProgressBar((int)$data->avg_user);?>" role="progressbar" aria-valuenow="<?php echo $data->avg_user;?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $data->avg_user;?>%">
						<span class="sr-only"><?php echo $data->percent;?>% Complete (warning)</span>
					</div>
				</div>
			</div>
                        <div><?php $timeUsed=round(((time()- strtotime($data->time_start))/(strtotime($data->time_end)-strtotime($data->time_start)))*100,0);
                                   if($timeUsed > 100 )$timeUsed = 100;
                                   if($timeUsed < 0)$timeUsed  = 0;
                        ?>
				<p>
					<strong><i class="fa fa-rocket"></i> Tiến độ thời gian</strong>
					<span class="pull-right text-muted text-warning">Còn lại <?php echo 100-$timeUsed;?>% </span>
				</p>
				<div class="progress progress-striped active">
					<div class="progress-bar <?php echo $fview->U_getProgressBar((int)$timeUsed);?>" role="progressbar" aria-valuenow="<?php echo $timeUsed;?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $timeUsed;?>%">
						<span class="sr-only"><?php echo $timeUsed;?>% Complete (warning)</span>
					</div>
				</div>
			</div>
			<!--<p><a class="btn btn-primary btn-lg" role="button">Learn more</a>
			</p>-->
		</div>
	</div>
	<!-- /.col-lg-12 -->
    
	<div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <i class="fa fa-thumb-tack"></i> Danh sách công việc của <span style="font-weight:bold;"><?php echo $data->user_report->fullname; ?></span> 
              </div>
            <!-- .panel-heading -->
            <div class="panel-body">
                <div class="panel-group" id="accordion">
                
                <?php $i = 1;$sum=0;$count=0; foreach ( $data->module AS $el2=>$le2 ){  $k = 0;?> 
                    <div class="panel panel-default">
                        <div class="panel-heading" style="overflow:auto">
                            <div class="panel-title">
                                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree<?php echo $i;?>" class="collapsed" aria-expanded="false"><i class="fa fa-check"></i> <?php echo $le2->module_name;?> ( <i class="fa fa-rocket"></i> <?php echo $le2->percent;?>% )</a>
                                    <div style="float:right;">
                                            <?php foreach ( $le2->module_user AS $value ){ //vòng lặp này chỉ in ra đúng?>
                                        
                                        <?php if($this->session->userdata("level") != 1) {?>
                                            <?php if($value->id == $this->session->userdata("admin_id")) {?>
                                                <span class="showProgess">
                                                    <input type="hidden" value="<?php echo $le2->id; ?>">
                                                    <?php if($le2->status == 1){ ?>
                                                    <a class="btn btn-default stopM" data-toggle="modal" data-target="#myModal<?php echo $le2->id; ?>">Tạm dừng</a>
                                                    <?php }else {?>
                                                    <a class="btn btn-default startM">Tiếp tục</a>
                                                    <?php }?>
                                                    <input class="progessNb"  value="<?php echo $value->rate;?>" type="number" id="replyNumber" min="0" max="100" data-bind="value:replyNumber" style="width:60px; "  disabled='disabled' />
                                                    <a  class="btn btn-default changePr buttonPr">OK</a>
                                                    <a  class="btn btn-default cancelPr buttonPr">Hủy</a>
                                                    <input type="hidden" value="<?php echo $le2->id;?>" class="idPr"/>
                            <!-- Modal -->
                            <div class="modal fade" id="myModal<?php echo $le2->id; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Lí do tạm dừng :</h4>
                                        </div>
                                        <div class="modal-body">
                                            <textarea class="form-control stopText" ></textarea>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default" data-dismiss="modal">Hủy</button>
                                            <button type="button" class="btn btn-primary stopmodal">Lưu lại</button>
                                        </div>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>
                            <!-- /.modal -->
                                                </span>
                                        <a class="submitProgess btn btn-success">Nhập tiến độ</a>
                                            <?php }
                                        }  elseif( $value->id == $uid)
                                        { ?>
                                            <span class="showProgess">
                                                    <input class="progessNb"  value="<?php echo $value->rate;?>" type="number" id="replyNumber" min="0" max="100" data-bind="value:replyNumber" style="width:50px; "  disabled='disabled' />
                                                </span>%
                                        <?php }
                                                
                                            }?>
                                        
                                    </div>
 
                            </div>
                        </div>
                        <div id="collapseThree<?php echo $i;?>" class="panel-collapse collapse" aria-expanded="false">
                            
                            <div class="panel-body">   
                                <p class="text-muted"><i class="fa fa-clock-o"></i> <?php echo ' Thời gian tạo : '.date('H:i d-m-Y',strtotime($le2->created)).' bởi '.$data->fullname;?> </p>

                                <p class="text-muted"><i class="fa fa-share-square"></i> <?php echo ' Thời gian hoạt động '.date('H:i d-m-Y',strtotime($le2->time_start)).' - '.date('H:i d-m-Y',strtotime($le2->time_end));?></p>

                                <p class="text-muted"><i class="fa fa-smile-o"></i> Trạng thái :
                                    <?php if($le2->percent >= 100){echo "Đã xử lí xong";}
                                          elseif($le2->status == 0){echo "Tạm dừng";}
                                          else{echo "Đang xử lí";}    
                                          
                                    ?> 
                                </p>  
                                 <?php if($le2->status == 0){?>
                                <p class="text-muted"><i class="fa-github-alt"></i> Lí do :
                                    
                                    <?php echo $le2->reason;  ?>
                                </p>   
                                <?php }?>
                                <p class="text-muted">
                                    <i class="fa fa-info-circle"></i> Mô tả : <br/>
                                    <div style="margin-left:16px;"><?php echo $le2->content;?></div>
                                </p>
                                <p class="text-muted">
                                    <i class="fa fa-user"></i> Người thực hiện<br> 
                                    <?php foreach ( $le2->module_user AS $value ){ ?>
                                        <div style="margin-left:16px;">
                                            <div class="col-md-3">
                                                <a href="<?php echo site_url('user-edit/'.$value->id);?>"><?php echo $value->fullname;?></a> 
                                            </div>
                                            <div class="col-md-7">
                                                <div class="progress progress-striped active">
                                                    <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo $value->rate; ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $value->rate; ?>%">
                                                        <span class="sr-only">Hoàn thành <?php echo $value->rate; ?>% </span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <span style="font-weight:bold;" class="pull-right text-muted">Hoàn thành <?php echo $value->rate; ?>%</span>
                                            </div>
                                        </div>
                                    <?php } ?> 
                                </p>
                                
                                <div style="margin-top:42px;" class="chat-panel panel panel-default">
                                        <div class="panel-heading">
                                            <i class="fa fa-comments fa-fw"></i>
                                            Comment trong module
                                            
                                            <i style="cursor:pointer;"class="fa fa-list pull-right hide_cm_md_m"></i>
                                        </div>
                                        <!-- /.panel-heading -->
                                        <div class="panel-body" style="height: auto !important;max-height: 150px;display: none;">
                                            <ul class="chat">
                                                <?php foreach ($le2->comment as $value)
                                                { ?>
                                                    <li class="left clearfix">
                                                        <span class="chat-img pull-left">
                                                            <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle">
                                                        </span>
                                                        <div class="chat-body" style=" word-wrap: break-word;">
                                                            <div class="header">
                                                                <strong class="primary-font"><?php echo $value->fullname; ?></strong>

                                                                <small class="pull-right text-muted">
                                                                    <input type="hidden" value=<?php echo $value->id; ?>>
                                                                    <i class="fa fa-clock-o fa-fw"></i> <?php echo date("d/m/Y H:i:s", strtotime($value->created)); ?>
                                                                    <?php if ($this->session->userdata("level") == 1)
                                                                    { ?>
                                                                        <button  class="btn btn-xs btn-danger comment_m_del">Xóa</button>
                                                                    <?php } ?>            
                                                                </small>
                                                            </div>
                                                            <p>
                                                                <?php echo $value->comment; ?>
                                                            </p>
                                                        </div>
                                                    </li>
                                                <?php } ?>
                                            </ul>
                                        </div>
                                        <!-- /.panel-body -->
                                        <div class="panel-footer" style="display:none;">
                                            <div class="form-group">
                                                <input type="hidden" value="<?php echo $le2->id;?>" >
                                                <textarea class="form-control comment_m" ></textarea>
                                                <button  style="margin-top:10px;" class="btn btn-primary btn-sm center-block comment_m_submit">
                                                    Gửi comment
                                                </button>
                                            </div>


                                        </div>
                                        <!-- /.panel-footer -->
                                    </div>
                            </div>
                        </div>
                    </div>
                <?php $i++; } ?>
                            
                  
                </div>
            </div>
            <!-- .panel-body -->
            <div class="panel-footer clearfix">
                <div style="float:right;font-weight: bold;">
                                Tiến độ trung bình: <?php echo round($data->avg_user);?>% 
                </div>
            </div>
        </div>
        <div class="chat-panel panel panel-default">
                        <div class="panel-heading">
                            <i class="fa fa-comments fa-fw"></i>
                            Comment trong dự án
                            <i style="cursor:pointer;"class="fa fa-list pull-right hide_cm_md_p"></i>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body" style="height: auto !important;max-height: 350px;display:none;">
                            <ul class="chat">
                                <?php foreach ($comment as $value) {?>
                                <li class="left clearfix">
                                    <span class="chat-img pull-left">
                                        <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle">
                                    </span>
                                    <div class="chat-body" style=" word-wrap: break-word;">
                                        <div class="header">
                                            <strong class="primary-font"><?php echo $value->fullname; ?></strong>
                                            
                                            <small class="pull-right text-muted">
                                                <input type="hidden" value=<?php echo $value->id; ?>>
                                                <i class="fa fa-clock-o fa-fw"></i> <?php echo date("d/m/Y H:i:s",strtotime($value->created)); ?>
                                                <?php if($this->session->userdata("level") == 1) {?>
                                                    <button  class="btn btn-xs btn-danger comment_p_del">Xóa</button>
                                                <?php } ?>            
                                            </small>
                                        </div>
                                        <p>
                                           <?php echo $value->comment; ?>
                                        </p>
                                    </div>
                                </li>
                                <?php }?>
                            </ul>
                        </div>
                        <!-- /.panel-body -->
                        <div class="panel-footer" style="display:none;">
                            <div class="form-group">
                                <textarea class="form-control" id="comment"></textarea>
                                <button  style="margin-top:10px;" class="btn btn-primary btn-sm center-block" id="comment_p_submit">
                                Gửi comment
                                </button>
                            </div>
                                
                            
                        </div>
                        <!-- /.panel-footer -->
        </div>    
            
        <div class="panel-chart">
                                        <div class="chart min">
                                            <div class="morris-bar" id="morris-bar-chart"></div>
                                        </div>
                                        <div style="text-align:center;margin-bottom: 30px;">
                                            <span style="font-weight: bold;">Bảng thống kê tiến độ theo ngày của <?php echo $data->user_report->fullname; ?> </span>
                                        </div>
        </div>   
        <!-- /.panel -->
    </div>
	<!-- /.col-lg-12 -->
</div>
<style>
    .buttonPr{display:none;}
</style>

<?php 
			$mrdata = '[';  
			foreach ( $process AS $el5=>$le5 ){ 
				$mrdata .= "{y: '".$le5->date."',a: ".$le5->rate."},";
			}
			$mrdata .= ']';
                       
		?>		
<script type="text/javascript">
		
        $(function() {
            Morris.Bar({
                element: 'morris-bar-chart',
                data: <?php echo $mrdata;?>,
                xkey: 'y',
                ykeys: 'a',
                ymax:100,
                labels: ['Tiến độ'],
                hideHover: 'auto',
                resize: true,
                parseTime: true
            });
        });
        
    </script>
<script type="text/javascript">
    $(function() {
        $( ".submitProgess" ).click(function() {
            $(this).parent().find(".buttonPr").toggle();
            $(this).parent().find(".progessNb").prop('disabled', function(i, v) { return !v; });
            
        });
        
        $( ".cancelPr" ).click(function() {
//            alert("123123");return;
            $(this).parent().find(".buttonPr").hide();
            $(this).parent().find(".progessNb").prop('disabled',true);
        });
        //Bấm đồng ý
        $( ".changePr" ).click(function() {
            
            var rate= $(this).parent().find(".progessNb").val();
            if(rate == ""){alert("Phần tỉ lệ hoàn thành công việc không được để trống!");return;}
            if(rate >100 || rate<0){alert("Tỉ lệ hoàn thành không quá 100 phần trăm!");return;}
            var module_id= $(this).parent().find(".idPr").val();
            kaka=$(this);
            $.ajax({
                type: 'GET',
                url: "<?php echo site_url() ;?>" + 'add-rate',
                data: ({rate: rate,module_id:module_id}),
                success: function(data) 
                {
                    alert(data);
                    window.location.reload();                 
                },
            });
        });
       $( "#comment_p_submit" ).click(function() {
            
            var comment= $(this).parent().find("#comment").val();  //lấy giá trị trong text area
            var project_id= <?php echo $data->id; ?>;
            var user_id= <?php echo $this->session->userdata("admin_id"); ?>;

            if(comment == ""){alert("Bạn không thể gửi comment rỗng!");return;}
            $.ajax({
                type: 'GET',
                url: "<?php echo site_url() ;?>" + 'add-comment-project',
                data: ({comment: comment,project_id:project_id,user_id:user_id}),
                success: function(data) 
                {
                    alert(data);
                    window.location.reload();                 
                },
            });
        });
        $( ".comment_p_del" ).click(function() {
            
            var commentId= $(this).parent().find("input[type=hidden]").val();
            if(confirm("Bạn có chắc chắn muốn xóa module này không?") == false)return;
            $.ajax({
                type: 'GET',
                url: "<?php echo site_url() ;?>" + 'del-comment-project',
                data: ({commentId: commentId}),
                success: function(data) 
                {
                    alert(data);
                    window.location.reload();                 
                },
            });
        });
      $( ".hide_cm_md_p" ).click(function(){
             $(this).parents(".chat-panel").find(".panel-body").toggle();
             $(this).parents(".chat-panel").find(".panel-footer").toggle();
             $("html, body").animate({ scrollTop: '+=350px' }, "slow"); // đấy xuống 1 tí
        });
        
      $( ".hide_cm_md_m" ).click(function(){
             $(this).parents(".chat-panel").find(".panel-body").toggle();
             $(this).parents(".chat-panel").find(".panel-footer").toggle();
             $("html, body").animate({ scrollTop: '+=150px' }, "slow"); // đấy xuống 1 tí
        });  
       $( ".comment_m_submit" ).click(function() {
           
            var comment= $(this).parent().find(".comment_m").val();  //lấy giá trị trong text area
            var module_id= $(this).parent().find("input[type=hidden]").val();
            var user_id= <?php echo $this->session->userdata("admin_id"); ?>;
            var project_id= <?php echo $data->id; ?>;
//            alert(comment+module_id+user_id);return;
            if(comment == ""){alert("Bạn không thể gửi comment rỗng!");return;}
            $.ajax({
                type: 'GET',
                url: "<?php echo site_url() ;?>" + 'add-comment-module',
                data: ({comment: comment,module_id:module_id,user_id:user_id,project_id:project_id}),
                success: function(data) 
                {
                    alert(data);
                    window.location.reload();                 
                },
            });
        });
        $( ".comment_m_del" ).click(function() {
            
            var commentId= $(this).parent().find("input[type=hidden]").val();
            
            if(confirm("Bạn có chắc chắn muốn xóa module này không?") == false)return;
            $.ajax({
                type: 'GET',
                url: "<?php echo site_url() ;?>" + 'del-comment-module',
                data: ({commentId: commentId}),
                success: function(data) 
                {
                    alert(data);
                    window.location.reload();                 
                },
            });
        });  
        $( ".stopmodal" ).click(function() {
            
            var module_id= $(this).parents(".showProgess").find("input[type=hidden]").val();
            var reason   =$(this).parents(".modal-content").find(".stopText").val();
            
            if(confirm("Bạn có chắc chắn muốn tạm dừng module này không?") == false)return;
            $.ajax({
                type: 'GET',
                url: "<?php echo site_url() ;?>" + 'stop-module',
                data: ({module_id: module_id,reason:reason}),
                success: function(data) 
                {
                    alert(data);
                    window.location.reload();                 
                },
            });
        });
//        
        $( ".startM" ).click(function() {
            
            var module_id= $(this).parent().find("input[type=hidden]").val();
           
            if(confirm("Bạn có chắc chắn muốn tiếp tục module này không?") == false)return;
            $.ajax({
                type: 'GET',
                url: "<?php echo site_url() ;?>" + 'start-module',
                data: ({module_id: module_id}),
                success: function(data) 
                {
                    alert(data);
                    window.location.reload();                 
                },
            });
        }); 
    });
    
    
</script>
<!-- /.row -->